<?
ob_start("ob_gzhandler");

require "include/bittorrent.php";
dbconn(false);
stdhead(Episodes);

//define shows here
$showcount = 3;

$showname[1] = "Lost";
$showimg[1] ="pic/episodes/lost.jpg";

$showname[2] = "Prison Break";
$showimg[2] ="pic/episodes/prisonbreak.jpg";

$showname[3] = "Heroes";
$showimg[3] ="pic/episodes/heroes.jpg";
//end


function get_show($show,$exact="",$episode="") 
{
	if (!$show) 
	{
		return FALSE;
	}

	if ($fp = fopen("http://www.tvrage.com/quickinfo.php?show=".urlencode($show)."&ep=".urlencode($episode)."&exact=".urlencode($exact),"r"))
	{
		while (!feof($fp))
		{
			$line = fgets($fp,1024);
			list ($sec,$val) = explode('@',$line,2);
			if ($sec == "Show Name")
			{
				$ret[0] = $val;
			}
			elseif ($sec == "Show URL")
			{
				$ret[1] = $val;
			}
			elseif ($sec == "Premiered")
			{
				$ret[2] = $val;
			}
			elseif ($sec == "Country")
			{
				$ret[7] = $val;
			}
			elseif ($sec == "Status")
			{
				$ret[8] = $val;
			}
			elseif ($sec == "Classification")
			{
				$ret[9] = $val;
			}
			elseif ($sec == "Latest Episode")
			{
				list ($ep,$title,$airdate) = explode('^',$val);
				$ret[3] = $ep.", \"".$title."\" aired on ".$airdate;
			}
			elseif ($sec == "Next Episode")
			{
				list ($ep,$title,$airdate) = explode('^',$val);
				$ret[4] = $ep.", \"".$title."\" airs on ".$airdate;
			}
			elseif ($sec == "Episode Info")
			{
				list ($ep,$title,$airdate) = explode('^',$val);
				$ret[5] = $ep.", \"".$title."\" aired on ".$airdate;
			}
			elseif ($sec == "Episode URL")
			{
				$ret[6] = $val;
			}
		}
		fclose($fp);
		if ($ret[0])
		{
			return $ret;
		}
	}
	else
	{
		return FALSE;
	}
}

for($i = 1; $i < $showcount+1; $i++) 
{
$show_infos1 = get_show("$showname[$i]","1");
print("<table border=1 width=500 cellspacing=0 cellpadding=1>\n");
print("<tr><td colspan=2 class=colhead align=center>".$show_infos1[0]."</td></tr>\n");
//print("<tr><td class=colhead align=center><img src=$showimg[$i]></td></tr>\n");
print("<tr><td align=center>Last Episode</td><td>".$show_infos1[3]."</td></tr>\n");
print("<tr><td align=center>Next Episode</td><td>".$show_infos1[4]."</td></tr>\n");
print("<tr><td align=center>Country</td><td>".$show_infos1[7]."</td></tr>\n");
print("<tr><td align=center>Status</td><td>".$show_infos1[8]."</td></tr>\n");
print("<tr><td align=center>Show Link</td><td><a class=altlink target=_blank href=".$show_infos1[1].">Link</a></td></tr>\n");
print("</table><br>\n");
}

stdfoot();
?>